<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>输入月份，显示当月天数（输入2月时需要再次输入年份判断是不是闰年后在显示当月天数）</title>
</head>
<body>
    <script>
        var month = parseInt(prompt('请输入月份'));
        switch (month) {
            case 4:
            case 6:
            case 9:
            case 11:
              alert('30');
              break;
            case 2: 
              var year = prompt('请输入年份');
              if (year % 100 === 0) {
                  if (year % 400 ===0) {
                      alert('闰年29');
                  } else {
                      alert('28') ; 
                  }
              } else if (year % 4 === 0) {
                  alert('闰年29');
              } else {
                  alert('28');
              }
              break
            default:
            alert('31')
        }
    </script>
</body>
</html>